/*-
 * ST.java          TP-Status (TP-ST)
 *
 * $LastChangedBy: stein $
 * $LastChangedRevision: 95 $
 * $LastChangedDate: 2007-02-13 16:19:24 +0000 (Tue, 13 Feb 2007) $
 * $HeadURL: svn://localhost/SMS/src/com/googlecode/attention/sms/pdu/ST.java $
 *
 * Copyright (c) 2007, Stein Gunnar Bakkeby
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of Stein Gunnar Bakkeby nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package com.googlecode.attention.sms.pdu;

import com.googlecode.attention.util.IntValue;
import com.googlecode.attention.util.bit.ByteBitValues;

/**
 * TP-Status (TP-ST).
 * <BR>
 * <BR>The TP-Status field indicates the status of a previously submitted
 * SMS-SUBMIT and certain SMS COMMANDS for which a Status -Report has been
 * requested. It consists of one octet and the bits in the octet are used
 * as follows.
 * <BR>
 * <BR>The MS shall interpret any reserved values as "Service Rejected"
 * (01100011) but shall store them exactly as received.
 * <BR>
 * <BR>bits value/usage
 * <BR>Bit 7 = 0: Bits 0..6 as defined below:
 * <BR>
 * <BR>6....0 Indicate whether the previously submitted short message was
 * successfully forwarded to the SME, or whether an error condition has been
 * encountered, as follows:
 * <BR>
 * <BR>Short message transaction completed (SMTC)
 * <BR>0000000 Short message received by the SME
 * <BR>0000001 Short message forwarded by the SC to the SME but the SC is unable to confirm delivery
 * <BR>0000010 Short message replaced by the SC
 * <BR>
 * <BR>Reserved values
 * <BR>0000011..0001111 Reserved
 * <BR>0010000..0011111 Values specific to each SC
 * <BR>
 * <BR>Temporary error, SC still trying to transfer SM (TEMP)
 * <BR>0100000 Congestion
 * <BR>0100001 SME busy
 * <BR>0100010 No response from SME
 * <BR>0100011 Service rejected
 * <BR>0100100 Quality of service not available
 * <BR>0100101 Error in SME
 * <BR>
 * <BR>0100110..0101111 Reserved
 * <BR>0110000..0111111 Values specific to each SC
 * <BR>
 * <BR>Permanent error, SC is not making any more transfer attempts
 * <BR>1000000 Remote procedure error
 * <BR>1000001 Incompatible destination
 * <BR>1000010 Connection rejected by SME
 * <BR>1000011 Not obtainable
 * <BR>1000100 Quality of service not available
 * <BR>1000101 No interworking available
 * <BR>1000110 SM Validity Period Expired
 * <BR>1000111 SM Deleted by originating SME
 * <BR>1001000 SM Deleted by SC Administration
 * <BR>1001001 SM does not exist (The SM may have previously existed in the SC but the SC no longer has knowledge of it or the SM may never have previously existed in the SC)
 * <BR>1001010..1001111 Reserved
 * <BR>1010000..1011111 Values specific to each SC
 * <BR>
 * <BR>Temporary error, SC is not making any more transfer attempts
 * <BR>1100000 Congestion
 * <BR>1100001 SME busy
 * <BR>1100010 No response from SME
 * <BR>1100011 Service rejected
 * <BR>1100100 Quality of service not available
 * <BR>1100101 Error in SME
 * <BR>1100110..1101001 Reserved
 * <BR>1101010..1101111 Reserved
 * <BR>1110000..1111111 Values specific to each SC
 * <BR>
 * <BR>
 * <BR>bits value/usage
 * <BR>Bit 7 = 1:  Bits 0..6 reserved
 * 
 * @author Stein Gunnar Bakkeby
 */
public class ST extends IntValue {
  
  /* Static field values */
  /* Short message transaction completed (SMTC). */
  /** Short message received by the SME. */
  public static final int SMTC_RECEIVED_BY_SME  = 0;
  /**
   * Short message forwarded by the SC to the SME
   * but the SC is unable to confirm delivery.
   */
  public static final int SMTC_FORWARDED_TO_SME = 1;
  /** Short message replaced by the SC. */
  public static final int SMTC_REPLACED_BY_SC   = 2;
  
  /* Values  3 to 15 reserved. */
  /* Values 16 to 31 specific to each SC. */ 
  
  /* Temporary error, SC still trying to transfer SM (TEMP_RETRY). */
  /** Congestion. */
  public static final int TEMP_RETRY_CONGESTION           = 32;
  /** SME busy. */
  public static final int TEMP_RETRY_SME_BUSY             = 33;
  /** No response from SME. */
  public static final int TEMP_RETRY_NO_RESPONSE_FROM_SME = 34;
  /** Service rejected. */
  public static final int TEMP_RETRY_SERVICE_REJECTED     = 35;
  /** Quality of service not available. */
  public static final int TEMP_RETRY_QOS_NOT_AVAILABLE    = 36;
  /** Error in SME. */
  public static final int TEMP_RETRY_ERROR_IN_SME         = 37;
  
  /* Values 38 to 47 reserved. */
  /* Values 48 to 63 specific to each SC. */
  
  /* Permanent error, SC is not making any more transfer attempts. */
  /** Remote procedure error. */
  public static final int PERM_REMOTE_PROCEDURE_ERROR       = 64;
  /** Incompatible destination. */
  public static final int PERM_INCOMPATIBLE_DESTINATION     = 65;
  /** Connection rejected by SME. */
  public static final int PERM_CONNECTION_REJECTED_BY_SME   = 66;
  /** Not obtainable. */
  public static final int PERM_NOT_OBTAINABLE               = 67;
  /** Quality of service not available. */
  public static final int PERM_QOS_NOT_AVAILABLE            = 68;
  /** No interworking available. */
  public static final int PERM_NO_INTERWORKING_AVAILABLE    = 69;
  /** SM Validity Period Expired. */
  public static final int PERM_SM_VALIDITY_PERIOD_EXPIRED   = 70;
  /** SM Deleted by originating SME. */
  public static final int PERM_DELETED_BY_ORIGINATING_SME   = 71;
  /** SM Deleted by SC Administration. */
  public static final int PERM_DELETED_BY_SC_ADMINISTRATION = 72;
  /**
   * SM does not exist (The SM may have previously existed in the SC but
   * the SC no longer has knowledge of it or the SM may never have
   * previously existed in the SC).
   */
  public static final int PERM_SM_DOES_NOT_EXIST            = 73;
  
  /* Values 74 to 79 reserved. */
  /* Values 80 to 95 specific to each SC. */
  
  /* Temporary error, SC is not making any more transfer attempts (TEMP). */
  /** Congestion. */
  public static final int TEMP_CONGESTION           =  96;
  /** SME busy. */
  public static final int TEMP_SME_BUSY             =  97;
  /** No response from SME. */
  public static final int TEMP_NO_RESPONSE_FROM_SME =  98;
  /** Service rejected. */
  public static final int TEMP_SERVICE_REJECTED     =  99;
  /** Quality of service not available. */
  public static final int TEMP_QOS_NOT_AVAILABLE    = 100;
  /** Error in SME. */
  public static final int TEMP_ERROR_IN_SME         = 101;
  
  /* Values 102 to 105 reserved. */
  /* Values 106 to 111 reserved. */
  /* Values 112 to 127 specific to each SC. */
  /* Values 128 to 255 reserved. */
  
  /* End static field values */
  
  /**
   * Constructor, uses the SMTC_RECEIVED_BY_SME status by default.
   */
  public ST() {
    super(SMTC_RECEIVED_BY_SME);
  }

  /**
   * Constructor, takes an int value as a parameter.
   * 
   * @param value The value of this object
   */
  public ST(final int value) {
    super(value);
  }
  
  /**
   * Constructor, takes a hex string as a parameter.
   * 
   * @param hex The value of this object in hex
   */
  public ST(final String hex) {
    super(hex);
  }
  
  /**
   * This will set the ST value. The integer must be in the range of 0 - 255,
   * otherwise it will be forced to 0 if < 0 or filtered by 0xFF if > 255.
   * 
   * @param value Integer that must be in the range of 0 - 255
   */
  public void setValue(int value) {
         if (value <   0) value = 0;
    else if (value > 255) value &= ByteBitValues.ALL;
    this.value = value;
  }
}